package com.dq.service.mall.impl;


import com.dq.domain.goods.ShoppingCart;
import com.dq.domain.sys.user.user.base.SysUser;
import com.dq.repository.AllRepository;
import com.dq.service.mall.ShoppingCartService;
import org.springframework.stereotype.Service;

@Service
public class ShoppingCartServiceImpl extends AllRepository implements ShoppingCartService {
    @Override
    public ShoppingCart getByUserAndOrg(SysUser user) {
        ShoppingCart cart = shoppingCartRepository.getByUser(user);
        if (null == cart) {
            cart = new ShoppingCart();
            cart.setUser(user);
            shoppingCartRepository.save(cart);
        }
        return cart;
    }
}
